<?php
/**
 * Created by PhpStorm.
 * User: 牛赞赞
 * Date: 2020/12/25
 * Time: 17:39
 */

namespace App\Game\Logic;


use App\Game\Conf\MainCmd;
use App\Game\Conf\SubCmd;
use App\Game\Core\AStrategy;
use App\Game\Core\Packet;
use App\Model\User;
use App\Service\Lock;
use App\Task\CreateRoomTask;

class CreateRoom extends AStrategy
{
    /**
     * 执行方法
     * 1.创建新房间，绑定user_room_map,user_room_wait,user_room_total
     * 2.返回新建房间数据
     */
    public function exec()
    {
        $account = $this->_params['userinfo']['account'];
        $fd = $this->_params['userinfo']['fd'];
        //防止重复操作
        if (!Lock::lock($account . '_create_room', 3)) {
            return;
        }
        //投递创建房间
        $task = container()->get(CreateRoomTask::class);
        $task->createRoom($fd, $account);
    }


}